package com.gun;

import com.gun.self_properties.MyProperties;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @Authar: 吾图南
 * @Data: 2022/12/4 16:18
 * @Package: com.gun
 * @ClassName: DemoMyPropertiesTest02
 * @Description: TODO
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class DemoMyPropertiesTest02 {


    @Autowired
    private MyProperties myProperties;
    @Autowired
    public ApplicationContext applicationContext;

    @Test
    public void  printMyProperties(){
        System.out.println(myProperties);
    }

    @Test
    public void printBean(){
        // 容器是否包含bean
        System.out.println(applicationContext.containsBean("myService"));
        // 通过id获取容器里面的bean实例
        System.out.println(applicationContext.getBean("myService"));
    }
}
